﻿using System;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;


/// <summary>
/// Summary description for Advertise
/// </summary>
/// 
namespace BusLogic
{
    public class Advertise
    {
        public static DataSet get_AdvertisePosition(int iPosition)
        {
            DataSet retData = new DataSet();
            String connString = ConfigurationManager.ConnectionStrings["DBDIENLANH"].ConnectionString;

            using (SqlConnection Conn = new SqlConnection(connString))
            {
                try
                {
                    String strCommandText;
                    SqlCommand objCommand;

                    strCommandText = @"SELECT * FROM ADVERTISE
                                WHERE POSITION = " + iPosition.ToString() + " AND RECORD_STATUS = 1 ORDER BY POSITION, SORTED ASC";

                    objCommand = new SqlCommand(strCommandText, Conn);
                    objCommand.CommandType = CommandType.Text;

                    SqlDataAdapter adap = new SqlDataAdapter(objCommand);
                    Conn.Open();
                    adap.Fill(retData, "Table");
                    Conn.Close();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (Conn.State == ConnectionState.Open)
                        Conn.Close();
                }
            }
            return retData;
        }

    }

}
